package cn.lyq.system.domain.asset.assetlifecycle;


import cn.lyq.codegen.processor.api.GenCreateRequest;
import cn.lyq.codegen.processor.api.GenQueryRequest;
import cn.lyq.codegen.processor.api.GenResponse;
import cn.lyq.codegen.processor.api.GenUpdateRequest;
import cn.lyq.codegen.processor.controller.GenController;
import cn.lyq.codegen.processor.creator.GenCreator;
import cn.lyq.codegen.processor.creator.IgnoreCreator;
import cn.lyq.codegen.processor.mapper.GenMapper;
import cn.lyq.codegen.processor.query.GenQuery;
import cn.lyq.codegen.processor.repository.GenRepository;
import cn.lyq.codegen.processor.service.GenService;
import cn.lyq.codegen.processor.service.GenServiceImpl;
import cn.lyq.codegen.processor.updater.GenUpdater;
import cn.lyq.codegen.processor.updater.IgnoreUpdater;
import cn.lyq.codegen.processor.vo.GenVo;
import cn.lyq.common.annotation.FieldDesc;
import cn.lyq.common.constants.ValidStatus;
import cn.lyq.jpa.converter.ValidStatusConverter;
import cn.lyq.jpa.support.BaseJpaAggregate;
import cn.lyq.system.domain.asset.assetrecord.InOutBizType;
import cn.lyq.system.domain.asset.assetrecord.InOutBizTypeConverter;
import cn.lyq.system.domain.asset.assetrecord.InOutType;
import cn.lyq.system.domain.asset.assetrecord.InOutTypeConverter;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

@GenVo(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.vo")
@GenCreator(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.creator")
@GenUpdater(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.updater")
@GenRepository(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.repository")
@GenService(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.service")
@GenServiceImpl(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.service")
@GenQuery(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.query")
@GenMapper(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.mapper")
@GenController(pkgName = "cn.lyq.system.controller")
@GenCreateRequest(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.request")
@GenUpdateRequest(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.request")
@GenQueryRequest(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.request")
@GenResponse(pkgName = "cn.lyq.system.domain.asset.assetlifecycle.response")
@Entity
@Table(name = "asset_lifecycle")
@Data
public class AssetLifecycle extends BaseJpaAggregate {

    @FieldDesc(name = "资产名称")
    private String name;

    @FieldDesc(name = "资产Id")
    private Long assetsId;

    private Long skuId;

    @FieldDesc(name = "唯一编码")
    private String uniqueCode;

    @FieldDesc(name = "备注")
    @Column(columnDefinition = "varchar(500)")
    private String remark;

    @FieldDesc(name = "仓库名称")
    private String houseName;

    @FieldDesc(name = "仓库id")
    private Long houseId;

    @FieldDesc(name = "出入库业务类型")
    @Convert(converter = InOutBizTypeConverter.class)
    private InOutBizType inOutBizType;

    @FieldDesc(name = "出入类型")
    @Convert(converter = InOutTypeConverter.class)
    private InOutType inOutType;

    @FieldDesc(name = "操作人")
    private String operateUser;

    @FieldDesc(name = "唯一批次号")
    private String genBatchNo;

    @FieldDesc(name = "批次号")
    private String batchNo;

    @Convert(converter = ValidStatusConverter.class)
    @IgnoreUpdater
    @IgnoreCreator
    private ValidStatus validStatus;

    public void init() {
        setValidStatus(ValidStatus.VALID);
    }

    public void valid(){
        setValidStatus(ValidStatus.VALID);
    }

    public void invalid(){
        setValidStatus(ValidStatus.INVALID);
    }
}
